﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Proyecta.Data.DAO
{
    public class ListColumnsDAO
    {
        conexion.SQL con = conexion.SQL.getSingleton();
        DataSet ds = null;
        string sqlsentencia;
        SqlCommand sqlcom;
        SqlDataAdapter Datos;

        public System.Data.DataSet Mostrar(string tabla)
        {
            sqlcom = new SqlCommand();
            Datos = new SqlDataAdapter();
            ds = new DataSet();
            sqlcom.Connection = con.conectar();
            con.abrir_conexion();
            sqlsentencia = "SELECT c.name 'Column Name',    c.max_length 'Max Length',    c.precision ,    c.scale ,    c.is_nullable FROM        sys.columns c WHERE    c.object_id = OBJECT_ID('"+tabla+"')";
            sqlcom.CommandText = sqlsentencia;
            Datos.SelectCommand = sqlcom;
            Datos.Fill(ds);
            con.cerrar_conexion();
            return ds;
        }

    }
}
